package com.uenpay.oem.widget.dialog;

import com.uenpay.oem.R;
import com.uenpay.oem.widget.view.VerificationCodeInput;

import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.view.Gravity;
import android.view.View;
import android.view.Window;
import android.widget.ImageView;
import android.widget.TextView;

/**
 * Created by PS on 2017/6/18.
 */

public class WithdrawDialog extends Dialog {

	private ImageView close_iv;
	private VerificationCodeInput message_code;
	private onMessageListenner onMessageclickListener;
	private TextView tv_message_money;

	private TextView tvpoundage;


	private onforgetpwdListenner onForgetPwd;
	private TextView tvforgetpwd;

	public WithdrawDialog(Context context) {
		super(context, R.style.dialog_custom);
	}

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_withdraw_dialog);
		Window window = getWindow();
		window.setGravity(Gravity.CENTER); // 此处可以设置dialog显示的位置为居中
		// 按空白处不能取消动画
		setCanceledOnTouchOutside(false);
		// 初始化控件
		initview();
		// 初始化界面控件的事件
		initEvent();

	}



	private void initEvent() {
		close_iv.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				dismiss();
			}
		});

		message_code.setOnCompleteListener(new VerificationCodeInput.Listener() {
			@Override
			public void onComplete(String content) {
				if (onMessageclickListener != null) {
					onMessageclickListener.onMessageclick(content);
				}

			}
		});

	tvforgetpwd.setOnClickListener(new View.OnClickListener() {
		@Override
		public void onClick(View v) {
			if (onForgetPwd!=null){
				onForgetPwd.onforgetpwdclick();
			}
		}
	});
	}

	public void setMessagemaney(String message) {
		if (message != null) {
			tv_message_money.setText(message);
		}
	}

	private void initview() {
		// 点击关闭
		close_iv = (ImageView) findViewById(R.id.dialog_close_code);
		// 验证码
		message_code = (VerificationCodeInput) findViewById(R.id.message_code);
		// 金额的方法
		tv_message_money = (TextView) findViewById(R.id.tv_message_money);

		tvforgetpwd = (TextView) findViewById(R.id.tv_forgetpwd);

		tvpoundage = (TextView) findViewById(R.id.tv_poundage);

	}



	public void  setPoundage(String Poundage){
		if (Poundage!=null){
			tvpoundage.setText("额外扣除¥"+Poundage+" 手续费");
		}
	}

	/**
	 * 短信验证码
	 */
	public void setOnMessageListenner(onMessageListenner onMessageListenner) {
		this.onMessageclickListener = onMessageListenner;

	}

	public interface onMessageListenner {
		void onMessageclick(String message);
	}

	/**
	 * 忘记密码
	 */

	public interface  onforgetpwdListenner{
		void onforgetpwdclick();
	}

	public void setonForgetPwdListenner(onforgetpwdListenner onforgetpwdListenner){
		this.onForgetPwd=onforgetpwdListenner;
	}
}
